package com.liangzhong.model.ladderMatch.vo
{
	import com.common.utils.Debug;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.compete.vo.CompeteMatchResultVo;
	import com.liangzhong.model.match.vo.MatchResultVo;
	
	import flash.utils.Dictionary;

	/**
	 *天梯信息 
	 * @author Administrator
	 * 
	 */	
	public class LadderInfoVo
	{
		public function LadderInfoVo()
		{
		}
		/**
		 *荣誉值 
		 */
		public var honour :int;
		/**
		 *天梯积分 
		 */
		public var ladderintegral:int;
		/**
		 *天梯等级 
		 * ABCDS
		 */
		public var ladderlevel :int;
		/**
		 * ABCDS中的排名 
		 * 等级中的排名
		 */
		public var levelrank :int;
		/**
		 *天梯排名 
		 */
		public var ladderrank :int;
		/**
		 *天梯挑战次数 
		 */
		public var laddercount :int;
		/**
		 *对抗点 
		 */
		public var rival :int;
		/**
		 *国内排名 
		 */
		public var nationrank :int;
		/**
		 * 
		 */
		public var clubid:int;
		
		/**
		 *上赛季排名前三 
		 */
		public var top3Dic:Dictionary;
		
		
		/**
		 *是否为自动比赛 
		 */
		public var isAutoMatch:Boolean 
		
		/**
		 * 使用的阵容
		 *  1.	第一阵容
		 * 	2.	第二阵容
		 */
		public var usebattle:int = 1;
		/**
		 *是否为报名状态 
		 */
		public var isApplyStatus:Boolean;
		/**
		 *比赛状态
		 * * 1.自动报名
		 * 2.取消自动报名
		 * 3.手动报名 
		 * 4.取消报名
		 */
		public var matchStatus:int = 4;
		
		
		/**
		 *比赛结果 
		 */
		public var matchresuelList:Array;
		
//		public var 
//		public var 
//		public var 
//		public var 
//		public var 
//		public var 
		public function analysis($obj:Object):void
		{
			for(var str:String in $obj)
			{
				if(this.hasOwnProperty(str))
					this[str] = $obj[str];
				else
					Debug.echo("LadderInfoVo 没有+ "+ str);
			}
		}
		/**
		 *上届天梯前三名 
		 * @param $arr
		 * 
		 */		
		public function topThird($arr:Array):void
		{
			if($arr==null)return;
			if(top3Dic == null)top3Dic= new Dictionary();
			var vo:RankVo;
			var obj:Object;
			for(var i:int = 0;i < $arr.length;i++)
			{
				vo = new RankVo();
				obj = $arr[i];
				vo.sort = obj.preladderrank ;
				vo.clubid = obj.clubid;
				vo.name = "<a href='event:"+vo.clubid+"'>"+obj.clubname +"</a>"
				top3Dic[obj.preladderrank ] = vo;
			}
		}
		/**
		 *解析比赛结果 
		 * 
		 */
		public function analysisMatchResult($arr:Array):void
		{
			
			if(matchresuelList == null)matchresuelList = new Array();
			if($arr == null)return;
			var len:int = $arr.length;
			var vo:CompeteMatchResultVo;
			var obj:Object;
			for(var i:int = 0;i < len;i++)
			{
				vo = new CompeteMatchResultVo();
				obj = $arr[i];
				vo.gId = obj.gcid;
				vo.ggold = obj.ggoal;
				vo.guname = obj.guname;
				vo.hId = obj.hcid;
				vo.hgold = obj.hgoal;
				vo.homeName = obj.huname;
				matchresuelList.push(vo);
			}
		}
		/**
		 *获得一场比赛结果 
		 * 
		 */
		public function getMatchOnceresult(resultVo:MatchResultVo):void
		{
			var vo:CompeteMatchResultVo;
			vo = new CompeteMatchResultVo();
			vo.gId = resultVo.gcid;
			vo.ggold = resultVo.ggold;
			vo.guname = resultVo.gname;
			vo.hId = AppData.getInstance().clubDatamanager.clubInfo.clubid;
			vo.hgold = resultVo.hgold;
			vo.homeName = AppData.getInstance().clubDatamanager.clubInfo.uname;
			matchresuelList.unshift(vo);
			if(matchresuelList.length > 10)
				matchresuelList.pop();
		}
		
	}
}